<?php

class AppController extends Controller {

    public $components = array(
        'Auth' => array(
            'authorize' => 'controller',
            'loginRedirect' => array(
                'admin' => false,
                'controller' => '',
                'action' => 'index'
            ),
            'loginError' => 'Invalid account specified',
            'authError' => 'You don\'t have the right permission'
        ),
        'Session'
    );

    public function beforeFilter() {
        $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'display', 'home');
        $this->Auth->logoutRedirect = '/';
        $this->Auth->allow('display');

        $this->loadModel('Category');
        $categories = $this->Category->find('all');
        $this->set('cat', $categories);

        $this->loadModel('Brand');
        $brands = $this->Brand->find('all');
        $this->set('brnd', $brands);

        $this->set('user', $this->Auth->user());

//        if ($this->Auth->getModel()->hasField('is_admin')) {
//            $this->Auth->userScope = array('is_admin' => 1);
//        }
    }

    public function isAuthorized() {
        return true;
    }

}

?>